package com.softwarerusher.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.softwarerusher.daoImpl.BookDAO;
import com.softwarerusher.model.TBook;

public class netshopdetail extends ActionSupport implements RequestAware,SessionAware{
	    private  String bookisbn;
	    private Map<String,Object> request;
	    private Map<String,Object> session;
	    private List<TBook> bookList;
        private List<TBook> book;
        public String detail()
        {
        	TBook book1 =  BookDAO.queryByISBN(bookisbn);
        	book = BookDAO.queryBookByCategoryId(-1, String.valueOf(book1.getTCategory().getCategoryId()) );
        	if(book.size()<6)
        	{
        		bookList = book.subList(0, book.size()-1);
        		
        	}
        	else 
        	{
        		bookList = book.subList(0, 5);
        	}
        	request.put("bookname", book1.getBookName());
        	request.put("bookpic", book1.getBookPic());
        	request.put("bookdescription", book1.getBookDescription());
        	request.put("bookprice", book1.getBookPrice());
        	request.put("bookisbn", bookisbn);
        	return "success";
        }
		public String getBookisbn() {
			return bookisbn;
		}
		public void setBookisbn(String bookisbn) {
			this.bookisbn = bookisbn;
		}
		public Map<String, Object> getRequest() {
			return request;
		}
		public void setRequest(Map<String, Object> request) {
			this.request = request;
		}
		public Map<String, Object> getSession() {
			return session;
		}
		public void setSession(Map<String, Object> session) {
			this.session = session;
		}
		public List<TBook> getBookList() {
			return bookList;
		}
		public void setBookList(List<TBook> bookList) {
			this.bookList = bookList;
		}
		public List<TBook> getBook() {
			return book;
		}
		public void setBook(List<TBook> book) {
			this.book = book;
		}
  
}